home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / rollerg.c < prev    next >
C/C++ Source or Header  |  2000-04-23  |  12KB  |  394 lines

  1. /***************************************************************************
  2.  
  3. Rollergames (GX999) (c) 1991 Konami
  4.  
  5. driver by Nicola Salmoria
  6.  
  7. ***************************************************************************/
  8.  
  9. #include "driver.h"
  10. #include "vidhrdw/generic.h"
  11. #include "vidhrdw/konamiic.h"
  12. #include "cpu/konami/konami.h" /* for the callback and the firq irq definition */
  13. #include "machine/eeprom.h"
  14.  
  15. /* prototypes */
  16. static void rollerg_init_machine( void );
  17. static void rollerg_banking( int lines );
  18.  
  19. int rollerg_vh_start(void);
  20. void rollerg_vh_stop(void);
  21. void rollerg_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  22.  
  23.  
  24.  
  25. static int readzoomroms;
  26.  
  27. static WRITE_HANDLER( rollerg_0010_w )
  28. {
  29. logerror("%04x: write %02x to 0010\n",cpu_get_pc(),data);
  30.  
  31.     /* bits 0/1 are coin counters */
  32.     coin_counter_w(0,data & 0x01);
  33.     coin_counter_w(1,data & 0x02);
  34.  
  35.     /* bit 2 enables 051316 ROM reading */
  36.     readzoomroms = data & 0x04;
  37.  
  38.     /* bit 5 enables 051316 wraparound */
  39.     K051316_wraparound_enable(0, data & 0x20);
  40.  
  41.     /* other bits unknown */
  42. }
  43.  
  44. static READ_HANDLER( rollerg_K051316_r )
  45. {
  46.     if (readzoomroms) return K051316_rom_0_r(offset);
  47.     else return K051316_0_r(offset);
  48. }
  49.  
  50. static READ_HANDLER( rollerg_sound_r )
  51. {
  52.     /* If the sound CPU is running, read the status, otherwise
  53.        just make it pass the test */
  54.     if (Machine->sample_rate != 0)     return K053260_r(2 + offset);
  55.     else return 0x00;
  56. }
  57.  
  58. static WRITE_HANDLER( soundirq_w )
  59. {
  60.     cpu_cause_interrupt(1,0xff);
  61. }
  62.  
  63. static void nmi_callback(int param)
  64. {
  65.     cpu_set_nmi_line(1,ASSERT_LINE);
  66. }
  67.  
  68. static WRITE_HANDLER( sound_arm_nmi_w )
  69. {
  70.     cpu_set_nmi_line(1,CLEAR_LINE);
  71.     timer_set(TIME_IN_USEC(50),0,nmi_callback);    /* kludge until the K053260 is emulated correctly */
  72. }
  73.  
  74. static READ_HANDLER( pip_r )
  75. {
  76.     return 0x7f;
  77. }
  78.  
  79. static struct MemoryReadAddress readmem[] =
  80. {
  81.     { 0x0020, 0x0020, watchdog_reset_r },
  82.     { 0x0030, 0x0031, rollerg_sound_r },    /* K053260 */
  83.     { 0x0050, 0x0050, input_port_0_r },
  84.     { 0x0051, 0x0051, input_port_1_r },
  85.     { 0x0052, 0x0052, input_port_4_r },
  86.     { 0x0053, 0x0053, input_port_2_r },
  87.     { 0x0060, 0x0060, input_port_3_r },
  88.     { 0x0061, 0x0061, pip_r },                /* ????? */
  89.     { 0x0300, 0x030f, K053244_r },
  90.     { 0x0800, 0x0fff, rollerg_K051316_r },
  91.     { 0x1000, 0x17ff, K053245_r },
  92.     { 0x1800, 0x1fff, paletteram_r },
  93.     { 0x2000, 0x3aff, MRA_RAM },
  94.     { 0x4000, 0x7fff, MRA_BANK1 },
  95.     { 0x8000, 0xffff, MRA_ROM },
  96.     { -1 }    /* end of table */
  97. };
  98.  
  99. static struct MemoryWriteAddress writemem[] =
  100. {
  101.     { 0x0010, 0x0010, rollerg_0010_w },
  102.     { 0x0020, 0x0020, watchdog_reset_w },
  103.     { 0x0030, 0x0031, K053260_w },
  104.     { 0x0040, 0x0040, soundirq_w },
  105.     { 0x0200, 0x020f, K051316_ctrl_0_w },
  106.     { 0x0300, 0x030f, K053244_w },
  107.     { 0x0800, 0x0fff, K051316_0_w },
  108.     { 0x1000, 0x17ff, K053245_w },
  109.     { 0x1800, 0x1fff, paletteram_xBBBBBGGGGGRRRRR_swap_w, &paletteram },
  110.     { 0x2000, 0x3aff, MWA_RAM },
  111.     { 0x4000, 0xffff, MWA_ROM },
  112.     { -1 }    /* end of table */
  113. };
  114.  
  115. static struct MemoryReadAddress readmem_sound[] =
  116. {
  117.     { 0x0000, 0x7fff, MRA_ROM },
  118.     { 0x8000, 0x87ff, MRA_RAM },
  119.     { 0xa000, 0xa02f, K053260_r },
  120.     { 0xc000, 0xc000, YM3812_status_port_0_r },
  121.     { -1 }    /* end of table */
  122. };
  123.  
  124. static struct MemoryWriteAddress writemem_sound[] =
  125. {
  126.     { 0x0000, 0x7fff, MWA_ROM },
  127.     { 0x8000, 0x87ff, MWA_RAM },
  128.     { 0xa000, 0xa02f, K053260_w },
  129.     { 0xc000, 0xc000, YM3812_control_port_0_w },
  130.     { 0xc001, 0xc001, YM3812_write_port_0_w },
  131.     { 0xfc00, 0xfc00, sound_arm_nmi_w },
  132.     { -1 }    /* end of table */
  133. };
  134.  
  135.  
  136. /***************************************************************************
  137.  
  138.     Input Ports
  139.  
  140. ***************************************************************************/
  141.  
  142. INPUT_PORTS_START( rollerg )
  143.     PORT_START
  144.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
  145.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 )
  146.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 )
  147.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER1 )
  148.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER1 )
  149.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER1 )
  150.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER1 )
  151.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START1 )
  152.  
  153.     PORT_START
  154.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
  155.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )
  156.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
  157.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER2 )
  158.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER2 )
  159.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER2 )
  160.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER2 )
  161.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 )
  162.  
  163.     PORT_START
  164.     PORT_DIPNAME( 0x0f, 0x0f, DEF_STR( Coin_A ) )
  165.     PORT_DIPSETTING(    0x02, DEF_STR( 4C_1C ) )
  166.     PORT_DIPSETTING(    0x05, DEF_STR( 3C_1C ) )
  167.     PORT_DIPSETTING(    0x08, DEF_STR( 2C_1C ) )
  168.     PORT_DIPSETTING(    0x04, DEF_STR( 3C_2C ) )
  169.     PORT_DIPSETTING(    0x01, DEF_STR( 4C_3C ) )
  170.     PORT_DIPSETTING(    0x0f, DEF_STR( 1C_1C ) )
  171.     PORT_DIPSETTING(    0x03, DEF_STR( 3C_4C ) )
  172.     PORT_DIPSETTING(    0x07, DEF_STR( 2C_3C ) )
  173.     PORT_DIPSETTING(    0x0e, DEF_STR( 1C_2C ) )
  174.     PORT_DIPSETTING(    0x06, DEF_STR( 2C_5C ) )
  175.     PORT_DIPSETTING(    0x0d, DEF_STR( 1C_3C ) )
  176.     PORT_DIPSETTING(    0x0c, DEF_STR( 1C_4C ) )
  177.     PORT_DIPSETTING(    0x0b, DEF_STR( 1C_5C ) )
  178.     PORT_DIPSETTING(    0x0a, DEF_STR( 1C_6C ) )
  179.     PORT_DIPSETTING(    0x09, DEF_STR( 1C_7C ) )
  180.     PORT_DIPSETTING(    0x00, DEF_STR( Free_Play ) )
  181.     PORT_DIPNAME( 0xf0, 0xf0, DEF_STR( Coin_B ) )
  182.     PORT_DIPSETTING(    0x20, DEF_STR( 4C_1C ) )
  183.     PORT_DIPSETTING(    0x50, DEF_STR( 3C_1C ) )
  184.     PORT_DIPSETTING(    0x80, DEF_STR( 2C_1C ) )
  185.     PORT_DIPSETTING(    0x40, DEF_STR( 3C_2C ) )
  186.     PORT_DIPSETTING(    0x10, DEF_STR( 4C_3C ) )
  187.     PORT_DIPSETTING(    0xf0, DEF_STR( 1C_1C ) )
  188.     PORT_DIPSETTING(    0x30, DEF_STR( 3C_4C ) )
  189.     PORT_DIPSETTING(    0x70, DEF_STR( 2C_3C ) )
  190.     PORT_DIPSETTING(    0xe0, DEF_STR( 1C_2C ) )
  191.     PORT_DIPSETTING(    0x60, DEF_STR( 2C_5C ) )
  192.     PORT_DIPSETTING(    0xd0, DEF_STR( 1C_3C ) )
  193.     PORT_DIPSETTING(    0xc0, DEF_STR( 1C_4C ) )
  194.     PORT_DIPSETTING(    0xb0, DEF_STR( 1C_5C ) )
  195.     PORT_DIPSETTING(    0xa0, DEF_STR( 1C_6C ) )
  196.     PORT_DIPSETTING(    0x90, DEF_STR( 1C_7C ) )
  197. //    PORT_DIPSETTING(    0x00, "Disabled" )
  198.  
  199.     PORT_START
  200.     PORT_DIPNAME( 0x03, 0x02, DEF_STR( Lives ) )
  201.     PORT_DIPSETTING(    0x03, "1" )
  202.     PORT_DIPSETTING(    0x02, "2" )
  203.     PORT_DIPSETTING(    0x01, "3" )
  204.     PORT_DIPSETTING(    0x00, "5" )
  205.     PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
  206.     PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
  207.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  208.     PORT_DIPNAME( 0x18, 0x10, "Bonus Energy" )
  209.     PORT_DIPSETTING(    0x00, "1/2 for Stage Winner" )
  210.     PORT_DIPSETTING(    0x08, "1/4 for Stage Winner" )
  211.     PORT_DIPSETTING(    0x10, "1/4 for Cycle Winner" )
  212.     PORT_DIPSETTING(    0x18, "None" )
  213.     PORT_DIPNAME( 0x60, 0x40, DEF_STR( Difficulty ) )
  214.     PORT_DIPSETTING(    0x60, "Easy" )
  215.     PORT_DIPSETTING(    0x40, "Normal" )
  216.     PORT_DIPSETTING(    0x20, "Hard" )
  217.     PORT_DIPSETTING(    0x00, "Hardest" )
  218.     PORT_DIPNAME( 0x80, 0x00, DEF_STR( Demo_Sounds ) )
  219.     PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
  220.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  221.  
  222.     PORT_START
  223.     PORT_DIPNAME( 0x01, 0x01, DEF_STR( Flip_Screen ) )
  224.     PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
  225.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  226.     PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
  227.     PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
  228.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  229.     PORT_SERVICE( 0x04, IP_ACTIVE_LOW )
  230.     PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
  231.     PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
  232.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  233.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_COIN2 )
  234.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN1 )
  235.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
  236.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN3 )
  237. INPUT_PORTS_END
  238.  
  239.  
  240.  
  241. /***************************************************************************
  242.  
  243.     Machine Driver
  244.  
  245. ***************************************************************************/
  246.  
  247. static struct YM3812interface ym3812_interface =
  248. {
  249.     1,
  250.     3579545,
  251.     { 80 },
  252.     { 0 },
  253. };
  254.  
  255. static struct K053260_interface k053260_interface =
  256. {
  257.     3579545,
  258.     REGION_SOUND1, /* memory region */
  259.     { MIXER(100,MIXER_PAN_LEFT), MIXER(100,MIXER_PAN_RIGHT) },
  260.     0
  261. };
  262.  
  263. static struct MachineDriver machine_driver_rollerg =
  264. {
  265.     /* basic machine hardware */
  266.     {
  267.         {
  268.             CPU_KONAMI,
  269.             3000000,        /* ? */
  270.             readmem,writemem,0,0,
  271.             interrupt,1
  272.         },
  273.         {
  274.             CPU_Z80 | CPU_AUDIO_CPU,
  275.             3579545,
  276.             readmem_sound, writemem_sound,0,0,
  277.             ignore_interrupt,0    /* IRQs are triggered by the main CPU */
  278.                                 /* NMIs are generated by the 053260 */
  279.         }
  280.     },
  281.     60, DEFAULT_REAL_60HZ_VBLANK_DURATION,    /* frames per second, vblank duration */
  282.     1,    /* 1 CPU slice per frame - interleaving is forced when a sound command is written */
  283.     rollerg_init_machine,
  284.  
  285.     /* video hardware */
  286.     64*8, 32*8, { 14*8, (64-14)*8-1, 2*8, 30*8-1 },
  287.     0,    /* gfx decoded by konamiic.c */
  288.     1024, 1024,
  289.     0,
  290.  
  291.     VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE,
  292.     0,
  293.     rollerg_vh_start,
  294.     rollerg_vh_stop,
  295.     rollerg_vh_screenrefresh,
  296.  
  297.     /* sound hardware */
  298.     0,0,0,0,
  299.     {
  300.         {
  301.             SOUND_YM3812,
  302.             &ym3812_interface
  303.         },
  304.         {
  305.             SOUND_K053260,
  306.             &k053260_interface
  307.         }
  308.     }
  309. };
  310.  
  311.  
  312.  
  313. /***************************************************************************
  314.  
  315.   Game ROMs
  316.  
  317. ***************************************************************************/
  318.  
  319. ROM_START( rollerg )
  320.     ROM_REGION( 0x28000, REGION_CPU1 ) /* code + banked roms */
  321.     ROM_LOAD( "999m02.g7",  0x10000, 0x18000, 0x3df8db93 )
  322.     ROM_CONTINUE(           0x08000, 0x08000 )
  323.  
  324.     ROM_REGION( 0x10000, REGION_CPU2 ) /* 64k for the sound CPU */
  325.     ROM_LOAD( "999m01.e11", 0x0000, 0x8000, 0x1fcfb22f )
  326.  
  327.     ROM_REGION( 0x200000, REGION_GFX1 ) /* graphics ( don't dispose as the program can read them ) */
  328.     ROM_LOAD( "999h06.k2",  0x000000, 0x100000, 0xeda05130 ) /* sprites */
  329.     ROM_LOAD( "999h05.k8",  0x100000, 0x100000, 0x5f321c7d )
  330.  
  331.     ROM_REGION( 0x080000, REGION_GFX2 ) /* graphics ( don't dispose as the program can read them ) */
  332.     ROM_LOAD( "999h03.d23", 0x000000, 0x040000, 0xea1edbd2 ) /* zoom */
  333.     ROM_LOAD( "999h04.f23", 0x040000, 0x040000, 0xc1a35355 )
  334.  
  335.     ROM_REGION( 0x80000, REGION_SOUND1 )    /* samples for 053260 */
  336.     ROM_LOAD( "999h09.c5",  0x000000, 0x080000, 0xc5188783 )
  337. ROM_END
  338.  
  339. ROM_START( rollergj )
  340.     ROM_REGION( 0x28000, REGION_CPU1 ) /* code + banked roms */
  341.     ROM_LOAD( "999v02.bin", 0x10000, 0x18000, 0x0dd8c3ac )
  342.     ROM_CONTINUE(           0x08000, 0x08000 )
  343.  
  344.     ROM_REGION( 0x10000, REGION_CPU2 ) /* 64k for the sound CPU */
  345.     ROM_LOAD( "999m01.e11", 0x0000, 0x8000, 0x1fcfb22f )
  346.  
  347.     ROM_REGION( 0x200000, REGION_GFX1 ) /* graphics ( don't dispose as the program can read them ) */
  348.     ROM_LOAD( "999h06.k2",  0x000000, 0x100000, 0xeda05130 ) /* sprites */
  349.     ROM_LOAD( "999h05.k8",  0x100000, 0x100000, 0x5f321c7d )
  350.  
  351.     ROM_REGION( 0x080000, REGION_GFX2 ) /* graphics ( don't dispose as the program can read them ) */
  352.     ROM_LOAD( "999h03.d23", 0x000000, 0x040000, 0xea1edbd2 ) /* zoom */
  353.     ROM_LOAD( "999h04.f23", 0x040000, 0x040000, 0xc1a35355 )
  354.  
  355.     ROM_REGION( 0x80000, REGION_SOUND1 )    /* samples for 053260 */
  356.     ROM_LOAD( "999h09.c5",  0x000000, 0x080000, 0xc5188783 )
  357. ROM_END
  358.  
  359.  
  360.  
  361. /***************************************************************************
  362.  
  363.   Game driver(s)
  364.  
  365. ***************************************************************************/
  366.  
  367. static void rollerg_banking( int lines )
  368. {
  369.     unsigned char *RAM = memory_region(REGION_CPU1);
  370.     int offs = 0;
  371.  
  372.  
  373.     offs = 0x10000 + ((lines & 0x07) * 0x4000);
  374.     if (offs >= 0x28000) offs -= 0x20000;
  375.     cpu_setbank(1,&RAM[offs]);
  376. }
  377.  
  378. static void rollerg_init_machine( void )
  379. {
  380.     konami_cpu_setlines_callback = rollerg_banking;
  381.  
  382.     readzoomroms = 0;
  383. }
  384.  
  385. static void init_rollerg(void)
  386. {
  387.     konami_rom_deinterleave_2(REGION_GFX1);
  388. }
  389.  
  390.  
  391.  
  392. GAME( 1991, rollerg,  0,       rollerg, rollerg, rollerg, ROT0, "Konami", "Rollergames (US)" )
  393. GAME( 1991, rollergj, rollerg, rollerg, rollerg, rollerg, ROT0, "Konami", "Rollergames (Japan)" )
  394.